<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('充值')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-vip-edit" th:object="${vipUser}">
            <input name="vipId" th:field="*{vipId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">充值金额：</label>
                <div class="col-sm-8">
                    <input name="balance" th:field="*{balance}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/vip";
        function submitHandler() {
            var balance=document.querySelector(`#form-vip-edit input[name='balance']`).value;
            $.ajax({
                type: "POST",
                url: prefix + "/chargevip",
                contentType: 'application/json',
                data:JSON.stringify(balance),
                success: function (response){
                    alert("充值成功")
                    $.modal.close();
                    // window.location.reload();
                    parent.window.location.reload();
                },
                error: function (xhr, status, error){
                    console.error(error);
                }
            })
        }


        // $("#form-vip-edit").validate({
        //     focusCleanup: true
        // });
        //
    </script>
</body>
</html>